import {BaseEle} from "./core.js";

class ZCheckCon extends BaseEle {
    constructor() {
        super();
        this._shadowRoot = this;
    }
    get value() {
        if (this._shadowRoot.children[0]) {
            return this._shadowRoot.children[0].checked;
        }
        else {
            throw new Error('no children');
        }
    }
    setValue(value) {
        if (this._shadowRoot.children[0]) {
            this._shadowRoot.children[0].checked = value;
        }
        else {
            throw new Error('no children');
        }
    }
    get _checkbox() {
        let checkboxList = this.querySelectorAll(":scope [type=checkbox]");
        return [...checkboxList];
    }
    attrChanged(name, oldValue, newValue) {
        this.setValue(this.hasAttribute('checked'));
    }
}

ZCheckCon.defsel('z-check-con', {
    attrs: {
        checked: false,
    }
});